package com.attms.service.impl;

import com.attms.domain.Absent;
import com.attms.dao.AbsentDao;
import com.attms.service.IAbsentService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author Team
 * @since 2022-12-18
 */
@Service
public class AbsentServiceImpl extends ServiceImpl<AbsentDao, Absent> implements IAbsentService {

    @Autowired
    private AbsentDao absentDao;
    @Override
    public Boolean createAbsence(Absent absent) {
        return absentDao.insert(absent) > 0;
    }

    @Override
    public Boolean deleteAbsence(Integer A_ID) {
        return absentDao.deleteById(A_ID) > 0;
    }

    @Override
    public Boolean updateAbsence(Absent absent) {
        return absentDao.updateById(absent) > 0;
    }

    @Override
    public List<Absent> searchAbsenceByEID(Integer E_ID) {
        LambdaQueryWrapper<Absent> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(Absent::getE_ID, E_ID);
        return absentDao.selectList(queryWrapper);
    }

    @Override
    public List<Absent> searchAbsenceByAID(Integer A_ID) {
        LambdaQueryWrapper<Absent> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(Absent::getA_ID, A_ID);
        return absentDao.selectList(queryWrapper);
    }
}
